# @Author     ：SEED
# @DateTime   ：2019-09-24  16:53 
# @FileName   ：project.py

from deployment.models import Project
from deployment.serializers.project_serializer import ProjectSerializer
from rest_framework import viewsets
from common.custom import CustomPagination, RbacPermission
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
from rest_framework_jwt.authentication import JSONWebTokenAuthentication


class ProjectViewSet(viewsets.ModelViewSet):
    """
    项目管理
    """
    perms_map = (
        {'*': 'admin'}, {'*': 'project_all'}, {'get': 'project_list'}, {'post': 'project_create'},
        {'put': 'project_edit'},
        {'delete': 'project_delete'})
    queryset = Project.objects.all()
    serializer_class = ProjectSerializer
    pagination_class = CustomPagination
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    search_fields = ('name',)
    # authentication_classes = (JSONWebTokenAuthentication,)
    # permission_classes = (RbacPermission,)